SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vwlConcursos
AS
SELECT dbo.tb_Concursos.idConcurso AS id, dbo.tb_Concursos.Descripcion AS Concurso, dbo.vwrConvocatorias.Descripcion AS Convocatorias, 
               dbo.tb_Concursos.Fecha, dbo.vwrLocalidades.Descripcion AS Localidad, dbo.vwrNivelesEnsenanza.Descripcion AS Nivel, 
               dbo.vwrModalidadesEnsenanza.Descripcion AS Modalidad, dbo.vwrEstadosConcursos.Descripcion AS Estado
FROM  dbo.tb_Concursos INNER JOIN
               dbo.vwrConvocatorias ON dbo.tb_Concursos.Convocatoria = dbo.vwrConvocatorias.ID INNER JOIN
               dbo.vwrEstadosConcursos ON dbo.tb_Concursos.Estado = dbo.vwrEstadosConcursos.Id LEFT OUTER JOIN
               dbo.vwrModalidadesEnsenanza ON dbo.tb_Concursos.Modalidad = dbo.vwrModalidadesEnsenanza.ID LEFT OUTER JOIN
               dbo.vwrNivelesEnsenanza ON dbo.tb_Concursos.Nivel = dbo.vwrNivelesEnsenanza.ID LEFT OUTER JOIN
               dbo.vwrLocalidades ON dbo.tb_Concursos.Localidad = dbo.vwrLocalidades.ID
GO
GRANT SELECT ON  [dbo].[vwlConcursos] TO [CentroDeDesignaciones]
GRANT SELECT ON  [dbo].[vwlConcursos] TO [Juntas]
GRANT SELECT ON  [dbo].[vwlConcursos] TO [SoloVer]
GO
